<style scoped>
</style>
<template>
  <van-field v-bind="$attrs"
             :placeholder="placeholder"
             :name="is_info?'':name"
             :model-value="modelValue"
             type="text"
             readonly
             :is-link="!is_info"
             @click="show_select_date" >
  </van-field>
</template>

<script>

import tool from "@/js/tool.js";

export default {
  name: "date",
  props: {
    name: String,
    modelValue: [String,Number],
    config: [String,Object],
    placeholder: String,
    is_info: Boolean,
  },
  emits: ['update:modelValue', 'change'],
  data() {
    return {
      need_display: true, //定义当modelValue变动时是否需要渲染，用来阻止当前组件变动 modelValue 后重新渲染
      fmt: this.config || 'Y-M-D',
      popup_show: false,
      content: '',
      picker_data: {
        selectedValues: [],
        selectedOptions: [],
      },
    }
  },
  methods: {
    display() {
    },
    show_select_date(){
      tool.select_date(this.fmt, this.modelValue).then(value => {
        this.need_display = false;
        setTimeout(()=>{this.need_display=true},10)
        this.$emit('update:modelValue', value);
        this.$emit('change', value);
      })
    },
  },
  watch: {
    config(v){
      this.fmt = this.config || 'Y-M-D';
    },
  },
  computed: {
  },
  mounted() {
  }
}
</script>